<?php

class HtmlTag {

	function _BasicTag( $sTag, $sContent, $sClass = null, $sId = null, $sOtherProperties = null ) {
		$sText = '<' . $sTag;
		if ( $sClass ) {
			$sText .= ' class="'.$sClass.'"';
		}
		if ( $sId ) {
			$sText .= ' id="'.$sId.'"';
		}
		$sText .= $sOtherProperties;
		if ( $sContent ) {
			$sText .= '>' . $sContent . '</'.$sTag.'>'. "\n";
		} else {
			$sText .= '/>';
		}
		return $sText;
	}
	
	function Anchor( $sContent, $sUrl = null ) {
		if ( !$sUrl ) {
			$sUrl = '#'.$sContent;	
		}
		return '<a href="'.htmlentities( $sUrl ).'">'.$sContent.'</a>';
	}
	
	function Br() {
		return '<br/>';	
	}
	
	function P( $sContent, $sClass = null, $sId = null ) {
		return HtmlTag::_BasicTag( 'p', $sContent, $sClass, $sId );
	}
	
	function H( $iLevel, $sContent, $sId = null ) {
		return HtmlTag::_BasicTag( 'h' . $iLevel, $sContent, null, $sId );
	}
	
	function Div( $sContent, $sClass = null, $sId = null ) {
		return HtmlTag::_BasicTag( 'div', $sContent, $sClass, $sId );
	}
	
	function Td( $sContent, $sClass = null, $sId = null ) {
		return HtmlTag::_BasicTag( 'td', $sContent, $sClass, $sId );
	}

	function Tr( $sContent, $sClass = null, $sId = null ) {
		return HtmlTag::_BasicTag( 'tr', $sContent, $sClass, $sId );
	}
	
	function Table( $sContent, $sClass = null, $sId = null ) {
		return HtmlTag::_BasicTag( 'table', $sContent, $sClass, $sId, ' cellspacing="0" cellpadding="0" border="1"' );
	}
	
	function Image( $sImageUrl, $sAlternativeText ) {
		return '<img src="'.$sImageUrl.'" alt="'.$sAlternativeText.'" />';
	}
	
	function _Input( $sName, $sValue, $sType, $sClass = '' ) {
		return HtmlTag::_BasicTag( 'input', null, $sClass, $sName, ' type="'.$sType.'" name="'.$sName.'" value="'.$sValue.'"');		
	}
	
	function TextInput( $sName, $sValue ) {
		return HtmlTag::_Input( $sName, $sValue, 'text' );
	}
	
	function HiddenInput( $sName, $sValue ) {
		return HtmlTag::_Input( $sName, $sValue, 'hidden' );
	}
	
	function InputBox( $sName, $sValue, $sLabel, $bEnabled = true ) {
		
		$sLabel = HtmlTag::_BasicTag( 'label', $sLabel, null, null, ' for="'.$sName.'"' );
		if ( $bEnabled ) {
			$sInput = HtmlTag::TextInput( $sName, $sValue );
		} else {
			$sInput = $sValue
					. HtmlTag::HiddenInput( $sName, $sValue );
		}	
		return $sLabel . $sInput . HtmlTag::Br();
	}
	
	function SubmitButton( $sName, $sValue ) {
		return HtmlTag::_Input( $sName, $sValue, 'submit', 'SubmitButton' );	
	}
}

?>
